package com.unicom.si.controller;

import com.unicom.si.pojo.Dept;
import com.unicom.si.security.pojo.CustomeUserDetail;
import com.unicom.si.service.DeptService;
import com.unicom.si.service.RoleService;
import com.unicom.si.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class DeptController {

    @Autowired
    private DeptService deptServ;

    @Autowired
    private RoleService roleServ;

    @Autowired
    private UserService userServ;

    @RequestMapping("/dept/{deptid}")
    public @ResponseBody Dept getDept(@PathVariable("deptid") int deptid) {

        System.out.println(roleServ.getClass());
        System.out.println(deptServ.getClass());

        roleServ.test();

        CustomeUserDetail user = userServ.queryUserByName("zhangsan");
        System.out.println("configuer = " + user.getUsername());
        System.out.println(userServ.getClass());


        return deptServ.queryDeptService(deptid);
    }

    @RequestMapping("/dept/id/{deptid}")
    public @ResponseBody Dept getDeptById(@PathVariable("deptid") int deptid) {

        return deptServ.checkDeptId(deptid);
    }
}
